package com.hxkj.controller;

import com.hxkj.domain.po.Content;
import com.hxkj.service.ContentService;
import com.platform.common.domain.result.ResultDataStruct;
import com.platform.common.domain.result.ResultMessageStruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Callable;

/**
 * @ClassName ContentController
 * @Description TODO
 * @Author Mr.zheng
 * @Date 2018/9/9 14:42
 * @Version 1.0
 */
@RestController
@RequestMapping("/content")
public class ContentController {

    @Autowired
    private ContentService contentService;

    /**
    * @author Mr.zheng
    * @Description getContent 根据文章ID获取映射内容
    **/
    @RequestMapping(value = "/getContent", method = RequestMethod.POST,consumes  ="application/json;charset=UTF-8")
    public Callable<ResultDataStruct<Content>> getContent(@RequestBody Content content) throws Exception{
        return () -> contentService.getContent(content);
    }



    /**
    * @author Mr.zheng
    * @Description saveContent 根据文章ID新增其映射内容
    **/
    @RequestMapping(value = "/saveContent", method = RequestMethod.POST,consumes  ="application/json;charset=UTF-8")
    public Callable<ResultMessageStruct> saveContent(@RequestBody Content content) throws Exception{
        return () -> contentService.saveContent(content);
    }
}
